<?php include "../public/header.php";?>
<?php include "../public/header_show.php";?>
<body id="xiangqingPage">
<div id="xiangqingBox">
    <div class="page-title">
        <div class="page-title-con">
            <span class="pageshowtitle">详情</span>
            <div class="page-title-opt-list">
                <?php include "../public_flow/flow_show_optbut.php";?>
                <button class="layui-btn layui-btn-sm btn-light marginr5 opt">
                    操作<i class="layui-icon layui-icon-down layui-font-12"></i>
                </button>
                <span id="page-close" class="page-close" onclick="layer_close()">×</span>
            </div>
        </div>
    </div>
    <div class="main-container">
        <div class="tongbox tongbox9">
            <div class="tuo">
                <div class="tit">合同名称</div>
                <div class="con" id="tong_name"></div>
            </div>
            <div class="tuo">
                <div class="tit">合同类型</div>
                <div class="con" id="tong_caihetype_name"></div>
            </div>
            <div class="tuo">
                <div class="tit">合同金额(元)</div>
                <div class="con" id="tong_money"></div>
            </div>
            <div class="tuo">
                <div class="tit">供应方(乙方)</div>
                <div class="con colorlan" id="tong_gonger"></div>
            </div>
            <div class="tuo">
                <div class="tit">项目名称</div>
                <div class="con colorlan" id="tong_enginname"></div>
            </div>
            <div class="tuo">
                <div class="tit">合同结算金额(元)</div>
                <div class="con colorlan" id="tong_lei_jie"></div>
            </div>
            <div class="tuo">
                <div class="tit">合同收票金额(元)</div>
                <div class="con colorlan" id="tong_lei_piaoshou"></div>
            </div>
            <div class="tuo">
                <div class="tit">合同审定付款(元)</div>
                <div class="con colorlan" id="tong_lei_shenfu"></div>
            </div>
            <div class="tuo">
                <div class="tit">合同已支付(元)</div>
                <div class="con colorlan" id="tong_lei_yifu"></div>
            </div>
        </div>

        <div><?php include "../public_flow/flow_show_info.php";?></div>

        <div class="table-box tablenes">
            <div class="title">基本信息</div>
            <table class="layui-table">
                <tbody>
                <tr><td class="tt">项目名称</td><td class="tv colorlan" id="enginname" colspan="3"></td></tr>

                <tr><td class="tt">合同名称</td><td id="name" class="tv"></td><td class="tt">合同状态</td><td id="state_name" class="tv"></td></tr>
                <tr><td class="tt">合同编号</td><td id="number" class="tv"></td><td class="tt">合同年份</td><td id="year" class="tv"></td></tr>
                <tr><td class="tt">合同类型</td><td id="caihetype_name" class="tv"></td><td class="tt">合同属性</td><td id="caiheshu" class="tv"></td></tr>
                <tr><td class="tt">供应方(乙方)</td><td id="gonger" class="tv"></td><td class="tt">采购方(甲方)</td><td id="caier_name" class="tv"></td></tr>
                <tr><td class="tt">乙方联系人</td><td id="gonguser" class="tv"></td><td class="tt">我方签订人</td><td id="myer" class="tv"></td></tr>
                <tr><td class="tt">乙方联系方式</td><td id="gongtel" class="tv"></td><td class="tt">签订日期</td><td id="qiandt" class="tv"></td></tr>
                <tr><td class="tt">合同金额(元)</td><td id="money" class="tv"></td><td class="tt">税率(%)</td><td id="rate" class="tv"></td></tr>
                <tr><td class="tt">合同开始日期</td><td id="startdt" class="tv"></td><td class="tt">合同结束日期</td><td id="enddt" class="tv"></td></tr>
                <tr><td class="tt">质保金比例(%)</td><td id="zhirate" class="tv"></td><td class="tt">质保金金额(元)</td><td id="zhifee" class="tv"></td></tr>

                <tr><td class="tt">结算方式</td><td class="tv" id="settle" colspan="3"></td></tr>
                <tr><td class="tt">支付条件</td><td class="tv" id="zhitiao" colspan="3"></td></tr>
                <tr><td class="tt">主要条款</td><td class="tv" id="clause" colspan="3"></td></tr>
                <tr><td class="tt">违约责任</td><td class="tv" id="viola" colspan="3"></td></tr>
                <tr><td class="tt">备注</td><td class="tv" id="explain" colspan="3"></td></tr>
                </tbody>
            </table>
        </div>

        <div><?php include "../public/upinfo_show.php";?></div>

        <div><?php include "../public_flow/flow_show_flowrelas.php";?></div>

        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo">合同变更</script>
            <div class="tableShow">
                <table id="datalist" lay-filter="datalist"></table>
            </div>
        </div>

        <div class="table-box tablenes">
            <script type="text/html" id="toolbarDemo_ming">
                <span>合同明细</span>
                <span class="colorhong layui-hide" id="havebudget">（红色数值表示已超出当前预算值，请谨慎审核！）</span>
            </script>
            <div class="tableShow">
                <table id="datalist_ming" lay-filter="datalist_ming"></table>
            </div>
        </div>

        <div><?php include '../public_flow/flow_show_shenlog.php'?></div>
        <div><?php include '../public_flow/flow_show_talk.php'?></div>
        <div><?php include '../public/opt_browse.php'?></div>
    </div>
</div>
<script>
    var param_id = getQueryVariable('id') || 0;

    layui.use(['form', 'layer', "laytp",'element','dropdown','laypage','table','soulTable'], function() {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable,element = layui.element;

        facade.ajax({url: ask_contract_cai_show, data:{id: param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;
                var engininfo = res.data.engininfo;

                $("#enginname").text(engininfo.name).click(function () {
                    openPage('../engin/show.php?id='+engininfo.id);
                });



                $("#tong_name").text(data.name);
                $("#tong_caihetype_name").text(data.caihetype_name);
                $("#tong_money").text(parseFormatNum(data.money));
                $("#tong_gonger").text(data.gonger).click(function () {
                    openPage('../tong_gong_gong/tong.php?gonger='+encodeURI(data.gonger), '80%', '80%');
                });
                $("#tong_enginname").text(engininfo.name).click(function () {
                    openPage('../engin/show.php?id='+engininfo.id);
                });
                $("#tong_lei_jie").text(parseFormatNum(data.lei_jie)).click(function () {
                    openPage('../tong_pub/gonglei.php?enginid='+encodeURI(engininfo.id)+'&cainame='+encodeURI(data.name)+'&caiid='+data.id, '80%', '80%');
                });
                $("#tong_lei_piaoshou").text(parseFormatNum(data.lei_piaoshou)).click(function () {
                    openPage('../piao_shou_hui/tong.php?enginname='+encodeURI(engininfo.name)+'&status=1'+'&cainame='+encodeURI(data.name), '80%', '80%');
                });
                $("#tong_lei_shenfu").text(parseFormatNum(data.lei_shenfu)).click(function () {
                    openPage('../payment_engin/tong.php?enginname='+encodeURI(engininfo.name)+'&cainame='+encodeURI(data.name)+'&status=1', '80%', '80%');
                });
                $("#tong_lei_yifu").text(parseFormatNum(data.lei_yifu)).click(function () {
                    openPage('../payment_engin/tong.php?enginname='+encodeURI(engininfo.name)+'&cainame='+encodeURI(data.name)+'&status=1', '80%', '80%');
                });



                $("#state_name").text(data.state_name);
                $("#name").text(data.name);
                $("#number").text(data.number);
                $("#year").text(data.year);
                $("#caihetype_name").text(data.caihetype_name);
                $("#caiheshu").text(data.caiheshu);
                $("#gonger").text(data.gonger);
                $("#caier_name").text(data.caier_name);
                $("#gonguser").text(data.gonguser);
                $("#myer").text(data.myer);
                $("#gongtel").text(data.gongtel);
                $("#qiandt").text(data.qiandt);
                $("#money").text(data.money);
                $("#rate").text(data.rate);
                $("#startdt").text(data.startdt);
                $("#enddt").text(data.enddt);
                $("#zhirate").text(data.zhirate);
                $("#zhifee").text(data.zhifee);
                $("#settle").text(data.settle);
                $("#zhitiao").text(data.zhitiao);
                $("#clause").text(data.clause);
                $("#viola").text(data.viola);
                $("#explain").text(data.explain);

                var mytableList = table.render({
                    elem: "#datalist",data:res.data.bian, toolbar: '#toolbarDemo', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号',fixed:'left'}
                        ,{field:'',title:'流程状态',templet: function(d){
                                if(d.billid > 0){
                                    if(d.status == 0){
                                        return '<span class="list_billid colorlan" onclick="openPage(\'../contract_bian/show.php?id='+d.id+'\');">流程(审批中)</span>'
                                    }else if(d.status == 1){
                                        return '<span class="list_billid colorlan" onclick="openPage(\'../contract_bian/show.php?id='+d.id+'\');">流程(审批通过)</span>'
                                    }else{
                                        return '';
                                    }
                                }else{
                                    return '<td>手动</td>';
                                }
                            }}
                        ,{field:'number',title:'变更单号',templet: function(d){
                                return '<span class="colorlan" onclick="show_contractbian('+d.id+')">'+d.number+'</span>';
                            }}
                        ,{field: 'bianfee', title: '本次变更金额(元)'}
                        ,{field: 'dt', title: '变更日期'}


                    ]]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });


                var subname_hide = true, yusuan_hide = true;
                var subname_field= '';
                if(data.is_budget){
                    subname_hide = false;
                    yusuan_hide = false;
                    subname_field = 'subname';
                }

                var runum_hide = true;
                var shengnum_hide = true;
                if(data.caihetype == 1){
                    runum_hide = false;
                    shengnum_hide = false;
                }

                var mytableList22 = table.render({
                    elem: "#datalist_ming",data:res.data.list, toolbar: '#toolbarDemo_ming', page: false
                    ,limit:TabInitShow.limit,soulSort: TabInitShow.soulSort,method: TabInitShow.method, overflow: TabInitShow.overflow
                    ,defaultToolbar: TabInitShow.defaultToolbar,filter: TabInitShow.filter ,text: TabInitShow.text
                    ,request: TabInitShow.request,response: TabInitShow.response,contextmenu:get_table_contextmenu(soulTable)
                    , cols: [[
                        {type:'numbers',title:'序号',fixed:'left'}
                        ,{field: subname_field, title: '成本科目',hide:subname_hide}
                        ,{field:'',title:'预算项',hide:yusuan_hide,templet: function(d){
                                return '<span class="colorlan" onclick="show_contractyusuan('+d.listid+')">'+d.guiname+'</span>';
                            }}
                        ,{field: 'name', title: '名称及规格'}
                        ,{field: 'unit', title: '单位'}
                        ,{field:'',title:'采购数量',templet: function(d){
                                if(d.chao_num){
                                    return '<span class="colorhong">'+d.num+'<span>';
                                }else{
                                    return d.num;
                                }
                            }}
                        ,{field: 'price', title: '采购单价(元)'}
                        ,{field:'',title:'采购金额(元)',templet: function(d){
                                if(d.chao_money){
                                    return '<span class="colorhong">'+d.money+'<span>';
                                }else{
                                    return d.money;
                                }
                            }}
                        ,{field: 'explain', title: '备注'}
                        ,{field: 'runum', title: '入库数量',hide:runum_hide}
                        ,{field: 'shengnum', title: '剩余可入库数量',hide:shengnum_hide}

                    ]]
                    , done: function (res) {
                        soulTable.render(this);

                        if(data.is_budget){
                            console.log(2222)
                            $("#havebudget").removeClass('layui-hide');
                        }
                    }
                });


                public_flow_show_display(res.data.billinfo);
                public_upload_show_file('upload_files', res.data.files);
                render_from();
            }
        });

        public_get_readsandlog('contract_cai', param_id);
    });

    function show_contractbian(id) {
        openPage('../contract_bian/show.php?id='+id);
    }

    function show_contractyusuan(listid) {
        openPage('bglist.php?listid='+listid);
    }



</script>
</body>
</html>




